package com.nsyue.auth.exception;

import com.nsyue.auth.controller.result.ApiStatusEnum;
import org.springframework.security.core.AuthenticationException;

/**
 * @Author laixm
 * @Date 2022/1/4 17:18
 * @ClassName SecurityException
 * @Description
 */
public class NsyueAuthException extends AuthenticationException {

    private Long errorCode;
    private String errorMessage;

    public NsyueAuthException(String msg, Throwable cause) {
        super(msg, cause);
        this.errorMessage = msg;
    }

    public NsyueAuthException(Long code, String msg) {
        super(msg);
        this.errorCode = code;
        this.errorMessage = msg;
    }

    public NsyueAuthException(Long errorCode, String errorMessage, Throwable cause) {
        super("[" + errorCode + "]" + errorMessage, cause);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public NsyueAuthException(ApiStatusEnum statusEnum) {
        this(statusEnum.getCode(), statusEnum.getMsg());
    }


    public Long getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Long errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}
